package com.hd.trans.ui.model

import androidx.lifecycle.MutableLiveData
import com.hd.trans.common.Constants.VOICE_NORMAL
import com.hd.trans.common.Constants.VOICE_RECOGNIZING
import com.hd.trans.common.Constants.VOICE_RECORD_PAUSE
import com.hd.trans.db.bean.HuDunLanguage

class VoiceTransViewModel: BaseViewModel() {
    val operateLanguage: MutableLiveData<HuDunLanguage> = MutableLiveData()
    val voiceState: MutableLiveData<Int> = MutableLiveData()
    val isFromLang: MutableLiveData<Boolean> = MutableLiveData()

    fun isFromLang(): Boolean {
        return isFromLang.value ?: true
    }

    fun isRecording(): Boolean {
        return voiceState.value == VOICE_RECOGNIZING
    }

    fun isPause(): Boolean {
        return voiceState.value == VOICE_RECORD_PAUSE
    }

    fun isStop(): Boolean {
        return voiceState.value == VOICE_NORMAL
    }

    fun getHdFromLanguage(): HuDunLanguage? {
        return if(isFromLang()){
            languageFrom.value
        }else{
            languageTo.value
        }
    }

    fun getHdToLanguage(): HuDunLanguage? {
        return if(isFromLang()){
            languageTo.value
        }else{
            languageFrom.value
        }
    }
}